﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NLog;
using TFMQTTService;

namespace IoTEdge.Grpc.Server
{
    public class BackgroundMQTTCollectPlugin : BackgroundService
    {
        NLog.ILogger logger = LogManager.GetCurrentClassLogger();
        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
        {
            var task = Task.Run(async () =>
               {
                   try
                   {
                       await new TFMQTT().Start();
                   }
                   catch (Exception ex)
                   {
                       logger.Fatal("【MQTTBroker】MQTTBroker已崩溃！请根据以下信息排查问题：" + ex.Message+"\n"+ex.InnerException?.Message);
                   }
                 
               });
            await Task.WhenAll(task);

        }
    }
}
